#
#  SSF.App.Worm Makefile
#

SHELL = /bin/sh


RELEASE = 0.5.1

#----------------------------------------------------------- SETUP

TOPDIR = ../../../..
include $(TOPDIR)/Makefile.common

JAVAC = javac $(JAVAC_FLAGS) -classpath $(SSFNET_TEST_CLASSPATH):$(PTII)
JAVA  = java  -classpath $(SSFNET_TEST_CLASSPATH)

PACKAGE_PATH = src/SSF/App/Worm

# files
SOURCES = WormProtocolSession.java MacroscopicModel.java \
	  MacroscopicModelConfigurator.java GatewayProtocolSession.java \
          ASGraph.java AS.java \
          WormEpidemic.java DeterministicWormEpidemic.java \
          WormEpidemicState.java DeterministicWormEpidemicState.java \
          StochasticWormEpidemic.java StochasticWormEpidemicState.java \
	  WormEpidemicInitializer.java UniformWormEpidemicInitializer.java \
	  GammaFunction.java ZeroGammaFunction.java CodeRedGammaFunction.java \
	  CodeRedWormEpidemicInitializer.java \
	  IPSpaceDistr.java CR2SuscFracDistr.java \
	  WormTraffic.java WormTrafficState.java \
	  MeanRateWormTraffic.java MeanRateWormTrafficState.java

OTHER_FILES = Makefile package.html README \
	      doc-files/abstraction_levels.fig \
	      test/singleHost.dml test/singleHost.ref \
	      test/twoASsingleHosts.dml test/twoASsingleHosts.ref \
	      test/campusUnderAttack.dml \
	      test/campusTestPlot.pl test/campusDataExtr.pl \
	      test/campus.gnuplot \
	      test/twoAStraffic.dml test/twoAStraffic.ref \
	      test/twoAStrafficDataExtr.pl test/twoAStraffic.gnuplot \
	      test/TestWormEpidemicInitializer.java

CLASSES = $(SOURCES:.java=.class)

# build flags
USERCFLAGS = -g

# general targets

#----------------------------------------------------------- MAKE ALL


.PHONY : all
all :	code

.PHONY : code
code :	$(CLASSES)
	@echo "---------- SSF.App.Worm package built -----------------------"

# classes

WormProtocolSession.class:	WormProtocolSession.java
	@echo ">>> building SSF.App.Worm package..."
	$(JAVAC) $(USERCFLAGS) WormProtocolSession.java

MacroscopicModel.class:	MacroscopicModel.java
	$(JAVAC) $(USERCFLAGS) MacroscopicModel.java

MacroscopicModelConfigurator.class:	MacroscopicModelConfigurator.java
	$(JAVAC) $(USERCFLAGS) MacroscopicModelConfigurator.java

GatewayProtocolSession.class:	GatewayProtocolSession.java
	$(JAVAC) $(USERCFLAGS) GatewayProtocolSession.java

ASGraph.class:	ASGraph.java
	$(JAVAC) $(USERCFLAGS) ASGraph.java

AS.class:	AS.java
	$(JAVAC) $(USERCFLAGS) AS.java

WormEpidemic.class:	WormEpidemic.java
	$(JAVAC) $(USERCFLAGS) WormEpidemic.java

DeterministicWormEpidemic.class:	DeterministicWormEpidemic.java
	$(JAVAC) $(USERCFLAGS) DeterministicWormEpidemic.java

WormEpidemicState.class:	WormEpidemicState.java
	$(JAVAC) $(USERCFLAGS) WormEpidemicState.java

DeterministicWormEpidemicState.class:	DeterministicWormEpidemicState.java
	$(JAVAC) $(USERCFLAGS) DeterministicWormEpidemicState.java

StochasticWormEpidemic.class:	StochasticWormEpidemic.java
	$(JAVAC) $(USERCFLAGS) StochasticWormEpidemic.java

StochasticWormEpidemicState.class:	StochasticWormEpidemicState.java
	$(JAVAC) $(USERCFLAGS) StochasticWormEpidemicState.java

WormEpidemicInitializer.class:	WormEpidemicInitializer.java
	$(JAVAC) $(USERCFLAGS) WormEpidemicInitializer.java

UniformWormEpidemicInitializer.class:	UniformWormEpidemicInitializer.java
	$(JAVAC) $(USERCFLAGS) UniformWormEpidemicInitializer.java

CodeRedWormEpidemicInitializer.class:	CodeRedWormEpidemicInitializer.java
	$(JAVAC) $(USERCFLAGS) CodeRedWormEpidemicInitializer.java

GammaFunction.class:	GammaFunction.java
	$(JAVAC) $(USERCFLAGS) GammaFunction.java

ZeroGammaFunction.class:	ZeroGammaFunction.java
	$(JAVAC) $(USERCFLAGS) ZeroGammaFunction.java

CodeRedGammaFunction.class:	CodeRedGammaFunction.java
	$(JAVAC) $(USERCFLAGS) CodeRedGammaFunction.java

IPSpaceDistr.class:	IPSpaceDistr.java
	$(JAVAC) $(USERCFLAGS) IPSpaceDistr.java

CR2SuscFracDistr.class:	CR2SuscFracDistr.java
	$(JAVAC) $(USERCFLAGS) CR2SuscFracDistr.java

WormTraffic.class:	WormTraffic.java
	$(JAVAC) $(USERCFLAGS) WormTraffic.java

WormTrafficState.class:	WormTrafficState.java
	$(JAVAC) $(USERCFLAGS) WormTrafficState.java

MeanRateWormTraffic.class:	MeanRateWormTraffic.java
	$(JAVAC) $(USERCFLAGS) MeanRateWormTraffic.java

MeanRateWormTrafficState.class:	MeanRateWormTrafficState.java
	$(JAVAC) $(USERCFLAGS) MeanRateWormTrafficState.java



#----------------------------------------------------------- MAKE JAVADOC

.PHONY : javadoc
javadoc: $(SOURCES)
	@echo ">>> making java documentation..."
	@if [ -d ./doc ]; then echo "./doc exists"; else echo "creating ./doc"; mkdir ./doc; fi
	javadoc -d ./doc -classpath $(SSFNET_TEST_CLASSPATH):$(PTII) $(SOURCES)
	@echo 'done.'



#----------------------------------------------------------- MAKE TESTS

tests:
	(cd test; $(MAKE))

#----------------------------------------------------------- MAKE CLEAN

.PHONY : clean
clean:
	@rm -f *.class
	(cd test; $(MAKE) clean)
	@echo 'Done.'

#----------------------------------------------------------- MAKE SPOTLESS

spotless:
	@find . \( -name "*.class" -o -name ".*~" -o -name "*~" \) -exec rm -f {} \;
	@rm -rf doc/javadoc/*
	@echo 'Done.'

#----------------------------------------------------------- MAKE RELEASE

# mark all current versions as one consistent release
# usage: make release NAME=<symbolic name>

.PHONY : release
release:
	@echo "Making release with name: $(NAME)"
	rcs -n$(NAME): $(SOURCES) $(OTHER_FILES)


#----------------------------------------------------------- MAKE GETCODEBASE

# retrieve sources from RCS repository

.PHONY : getcodebase
getcodebase:
	@echo "Retrieving sources"
	co $(SOURCES)


#----------------------------------------------------------- MAKE TARBALL

# retrieve sources from RCS repository

.PHONY : tarball
tarball:
	@echo "Creating release tarball in directory $(TOPDIR) (SSFNet root)"
	cd $(TOPDIR); tar -zcvf worm$(RELEASE).tgz $(PACKAGE_PATH)/README $(PACKAGE_PATH)/*.java $(PACKAGE_PATH)/Makefile $(PACKAGE_PATH)/*.html $(PACKAGE_PATH)/doc-files $(PACKAGE_PATH)/test/Makefile $(PACKAGE_PATH)/test/*.dml $(PACKAGE_PATH)/test/*.java $(PACKAGE_PATH)/test/*.pl $(PACKAGE_PATH)/test/*.adj $(PACKAGE_PATH)/test/*.gnuplot $(PACKAGE_PATH)/test/*.ref examples/wormDemo
	@ # perhaps use variable lists defined above instead?



#  $Id: Makefile,v 1.12 2003/03/08 01:55:52 mili Exp mili $
